import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
	state: {
		playerStare: '', //当前播放音频状态
		playList: [], //当前播放列表
		playingIindex: null, // 当前播放音频下标
		currnetSong: { //当前播放歌曲详情
			al: {},
			ar: [],
			artists:{},
		},
		currentTime:0,
		currentDuration:0
		
	},
	mutations: {
		setCurrnetSong(state, data) {
			// window.console.log(data);
			state.currnetSong = data;
		},
		changePlayerState(state, type) {
			state.playerStare = type;
		},
		setPlaySongList(state, idList) {
			state.playList = idList;
		},
		setPlayingIndex(state, index) {
			state.playingIindex = index;
		},
		preSong(state) {
			if (state.playingIindex == 0) {
				state.playingIindex = state.playList.length - 1;
			} else {
				state.playingIindex--;
			}
		},
		nextSong(state) {
			if (state.playingIindex == state.playList.length - 1) {
				state.playingIindex = 0;
			} else {
				state.playingIindex++;
			}
		},
		getCurrentTime(state,data){
			this.state.currentTime = data.curTime;
			this.state.currentDuration = data.cuDuration;
		}, 
	},
	actions: {},
	modules: {}
})
